class InitTourGroupsBjCostAndTotalCost < ActiveRecord::Migration
  def self.up
    for tour_group in TourGroup.find(:all)
      # 初始化北京成本
      tour_group.bj_cost = 0
      tour_group.bj_cost += tour_group.lodging.lodging_cost
      tour_group.bj_cost += tour_group.guide_involved.food_cost
      tour_group.bj_cost += tour_group.guide_involved.attraction_ticket_cost
      tour_group.bj_cost += tour_group.guide_involved.subsidy_for_guide
      tour_group.bj_cost += tour_group.vehicle.travel_cost
      # 初始化总成本
      tour_group.total_cost = tour_group.bj_cost + tour_group.outer_expense.total_cost
      
      tour_group.save
    end
  end

  def self.down
  end
end
